package com.sinosoft.config.jdbc;

import com.sinosoft.config.jdbc.dataSource.DataSourceType;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: zouren
 * @Date: 2019/5/10 16:03
 * @Description:
 */
@Getter
public enum DBEnum {
    MASTER(DataSourceType.write.getType()), SLAVE1(DataSourceType.read.getType()), SLAVE2(DataSourceType.read.getType());
    private DBEnum(String dataSourceType){
        this.dataSourceType = dataSourceType;
    }
    private String dataSourceType;

    /**
     * 使用判断数据源的类型
     * @return
     */
    @Override
    public String toString(){
        return this.name()+"_"+this.getDataSourceType();
    }

    public static void main(String[] args) {
        Map<Object, Object> targetDataSources = new HashMap<>();
        targetDataSources.put(DBEnum.MASTER, "1");
        System.out.println(DBEnum.MASTER);
        System.out.println( targetDataSources.get(DBEnum.MASTER));
        DBEnum aa = (DBEnum) targetDataSources.keySet().iterator().next();
        System.out.println(aa.getDataSourceType());
    }
}
